home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / cg.lha / cg / src / c1.puma < prev    next >
Text File  |  1992-11-24  |  32KB  |  1,188 lines

  1. /* Ich, Doktor Josef Grosch, Informatiker, 28.6.1990 */
  2.  
  3. TRAFO TreeC1
  4. TREE Tree
  5. PUBLIC TreeDefC TreeImplC
  6.  
  7. EXPORT {
  8. CONST BSS    = 8;    (* BITSET size *)
  9. }
  10.  
  11. GLOBAL {
  12.  
  13. FROM General    IMPORT Max;
  14. FROM IO        IMPORT WriteS, WriteNl;
  15. FROM Idents    IMPORT tIdent;
  16. FROM Texts    IMPORT WriteText;
  17. FROM Sets    IMPORT IsElement, Include;
  18. FROM TreeC2    IMPORT TreeIO, GetIterator, Iterator, WriteLine;
  19.  
  20. FROM Tree    IMPORT
  21.    NoTree    , tTree        , Input        , Reverse    ,
  22.    Class    , Child        , Attribute    , Abstract    ,
  23.    HasChildren    , HasAttributes    , NoCodeAttr    , NoCodeClass    ,
  24.    Options    , TreeRoot    , ClassCount    , iNoTree    ,
  25.    itTree    , iMain        , iModule    , f        ,
  26.    WI    , WN    , ForallClasses    , ForallAttributes, Ignore    ,
  27.    Test        , Dummy        ;
  28.  
  29. IMPORT Strings;
  30.  
  31. VAR
  32.    ConstCount    ,
  33.    ListCount    : INTEGER;
  34.    iRange    ,
  35.    iClassName    : tIdent;
  36.    Node        : tTree;
  37.    gBitCount    : SHORTCARD;
  38.    i, MaxBit    : SHORTCARD;
  39. }
  40.  
  41. BEGIN { ConstCount := 0; }
  42.  
  43. PROCEDURE TreeDefC (t: Tree)
  44.  
  45. Ag (..) :- {
  46.     !# ifndef yy! WI (iModule); !!
  47.     !# define yy! WI (iModule); !!
  48.     !!
  49.     !# if defined __STDC__ | defined __cplusplus!
  50.     !# define ARGS(parameters)    parameters!
  51.     !# else!
  52.     !# define ARGS(parameters)    ()!
  53.     !# endif!
  54.     !!
  55.       IF IsElement (ORD ('<'), Options) THEN
  56.     @# include "@ WI (iMain); @.h"@
  57.       END;
  58.     WriteLine (TreeCodes^.Codes.ImportLine);
  59.     WriteText (f, TreeCodes^.Codes.Import);
  60.     Node := Modules;
  61.     WHILE Node^.Kind = Tree.Module DO
  62.        WriteLine (Node^.Module.TreeCodes^.Codes.ImportLine);
  63.        WriteText (f, Node^.Module.TreeCodes^.Codes.Import);
  64.        Node := Node^.Module.Next;
  65.     END;
  66.     !!
  67.     !# ifndef bool!
  68.     !# define bool char!
  69.     !# endif!
  70.       IF NOT IsElement (ORD ('<'), Options) THEN
  71.     !# define ! WI (iNoTree); ! (! WI (itTree); !) 0L!
  72.     ForallClasses (Classes, ConstDecls);
  73.     !!
  74.     IF ClassCount > 251 THEN
  75.     !typedef unsigned short ! WI (iMain); !_tKind;!
  76.     ELSE
  77.     !typedef unsigned char ! WI (iMain); !_tKind;!
  78.     END;
  79.     !typedef unsigned short ! WI (iMain); !_tMark;!
  80.     !typedef unsigned short ! WI (iMain); !_tLabel;!
  81.     !typedef union ! WI (iMain); !_Node * ! WI (itTree); !;!
  82.     !typedef void (* ! WI (iMain); !_tProcTree) ARGS((! WI (itTree); !));!
  83.       END;
  84.     WriteLine (TreeCodes^.Codes.ExportLine);
  85.     WriteText (f, TreeCodes^.Codes.Export);
  86.     Node := Modules;
  87.     WHILE Node^.Kind = Tree.Module DO
  88.        WriteLine (Node^.Module.TreeCodes^.Codes.ExportLine);
  89.        WriteText (f, Node^.Module.TreeCodes^.Codes.Export);
  90.        Node := Node^.Module.Next;
  91.     END;
  92.     !!
  93.       IF NOT IsElement (ORD ('<'), Options) THEN
  94.     !# ifndef ! WI (iMain); !_NodeHead!
  95.     !# define ! WI (iMain); !_NodeHead!
  96.     !# endif!
  97.       IF IsElement (ORD ('L'), Options) THEN
  98.     MaxBit := 0;
  99.     ForallClasses (Classes, CompMaxBit);
  100.     !typedef struct { ! WI (iMain); !_tKind yyKind; unsigned char yyIsComp0! 
  101.       IF IsElement (ORD ('5'), Options) THEN
  102.     !, yyIsDone0! 
  103.       END;
  104.     FOR i := 1 TO (MaxBit - 1) DIV BSS DO
  105.        !, yyIsComp! WN (i);
  106.       IF IsElement (ORD ('5'), Options) THEN
  107.        !, yyIsDone! WN (i);
  108.       END;
  109.     END;
  110.     !; ! WI (iMain); !_tMark yyMark, yyOffset; ! WI (itTree); ! yyParent; ! 
  111.     WI (iMain); !_NodeHead } ! WI (iMain); !_tNodeHead;!
  112.       ELSE
  113.     !typedef struct { ! WI (iMain); !_tKind yyKind; ! WI (iMain); !_tMark yyMark; ! 
  114.     WI (iMain); !_NodeHead } ! WI (iMain); !_tNodeHead;!
  115.       END;
  116.     ForallClasses (Classes, TypeDeclNode);
  117.     !!
  118.     !union ! WI (iMain); !_Node {!
  119.     ! ! WI (iMain); !_tKind Kind;!
  120.     ! ! WI (iMain); !_tNodeHead yyHead;!
  121.     ForallClasses (Classes, TypeDeclRecord);
  122.     !};!
  123.     !!
  124.     !extern ! WI (itTree); ! ! WI (iMain); !Root;!
  125.     !extern unsigned long ! WI (iMain); !_HeapUsed;!
  126.     !extern char * ! WI (iMain); !_PoolFreePtr, * ! WI (iMain); !_PoolMaxPtr;!
  127.     !extern unsigned short ! WI (iMain); !_NodeSize [! WN (ClassCount); ! + 1];!
  128.     !extern char * ! WI (iMain); !_NodeName [! WN (ClassCount); ! + 1];!
  129.     !!
  130.     !extern void (* ! WI (iMain); !_Exit) ();!
  131.     !extern ! WI (itTree); ! ! WI (iMain); !_Alloc ();!
  132.     !extern ! WI (itTree); ! Make! WI (iMain); ! ARGS((! WI (iMain); !_tKind yyKind));!
  133.     !extern bool ! WI (iMain); !_IsType ARGS((register ! WI (itTree); ! yyt, register ! WI (iMain); !_tKind yyKind));!
  134.     !!
  135.       END;
  136.       IF IsElement (ORD ('n'), Options) THEN
  137.     ForallClasses (Classes, ProcedureDeclsn);
  138.     !!
  139.       END;
  140.       IF IsElement (ORD ('m'), Options) THEN
  141.     ForallClasses (Classes, ProcedureDeclsm);
  142.     !!
  143.       END;
  144.       IF IsElement (ORD ('f'), Options) THEN
  145.     !extern void Release! WI (iModule); ! ARGS((! WI (itTree); ! yyt));!
  146.       END;
  147.       IF IsElement (ORD ('F'), Options) AND NOT IsElement (ORD ('<'), Options) THEN
  148.     !extern void Release! WI (iModule); !Module ();!
  149.       END;
  150.       IF IsElement (ORD ('o'), Options) THEN
  151.     !extern void Write! WI (iModule); !Node ARGS((FILE * yyyf, ! WI (itTree); ! yyt));!
  152.       END;
  153.       IF IsElement (ORD ('w'), Options) THEN
  154.     !extern void Write! WI (iModule); ! ARGS((FILE * yyyf, ! WI (itTree); ! yyt));!
  155.       END;
  156.       IF IsElement (ORD ('r'), Options) THEN
  157.     !extern ! WI (itTree); ! Read! WI (iModule); ! ARGS((FILE * yyyf));!
  158.       END;
  159.       IF IsElement (ORD ('p'), Options) THEN
  160.     !extern void Put! WI (iModule); ! ARGS((FILE * yyyf, ! WI (itTree); ! yyt));!
  161.       END;
  162.       IF IsElement (ORD ('g'), Options) THEN
  163.     !extern ! WI (itTree); ! Get! WI (iModule); ! ARGS((FILE * yyyf));!
  164.       END;
  165.       IF IsElement (ORD ('t'), Options) THEN
  166.     !extern void Traverse! WI (iModule); !TD ARGS((! WI (itTree); ! yyt, ! WI (iMain); !_tProcTree yyyProc));!
  167.       END;
  168.       IF IsElement (ORD ('b'), Options) THEN
  169.     !extern void Traverse! WI (iModule); !BU ARGS((! WI (itTree); ! yyt, ! WI (iMain); !_tProcTree yyyProc));!
  170.       END;
  171.       IF IsElement (ORD ('R'), Options) THEN
  172.     !extern ! WI (itTree); ! Reverse! WI (iModule); ! ARGS((! WI (itTree); ! yyOld));!
  173.       END;
  174.       IF IsElement (ORD ('y'), Options) THEN
  175.     !extern ! WI (itTree); ! Copy! WI (iModule); ! ARGS((! WI (itTree); ! yyt));!
  176.       END;
  177.       IF IsElement (ORD ('k'), Options) THEN
  178.     !extern bool Check! WI (iModule); ! ARGS((! WI (itTree); ! yyt));!
  179.       END;
  180.       IF IsElement (ORD ('q'), Options) THEN
  181.     !extern void Query! WI (iModule); ! ARGS((! WI (itTree); ! yyt));!
  182.       END;
  183.       IF IsElement (ORD ('='), Options) THEN
  184.     !extern bool IsEqual! WI (iModule); ! ARGS((! WI (itTree); ! yyt1, ! WI (itTree); ! yyt2));!
  185.       END;
  186.       IF IsElement (ORD ('L'), Options) THEN
  187.     !extern void Init! WI (iModule); ! ARGS((register ! WI (itTree); ! yyt));!
  188.       END;
  189.     !extern void Begin! WI (iModule); ! ();!
  190.     !extern void Close! WI (iModule); ! ();!
  191.     !!
  192.     !# endif!
  193. }; .
  194.  
  195.  
  196. PROCEDURE ConstDecls (t: Tree)
  197.  
  198. Class (..) :- {
  199.     IF NOT (Abstract IN Properties) THEN
  200.        INC (ConstCount);
  201.        IF NOT (Ignore IN Properties) THEN
  202.           !# define k! WI (Name); ! ! WN (ConstCount); !!
  203.        END;
  204.     END;
  205. }; .
  206.  
  207.  
  208. PROCEDURE TypeDeclNode (t: Tree)
  209.  
  210. Class (..) :- {
  211.     IF (NoCodeClass * Properties) = {} THEN
  212.        !typedef struct { ! WI (iMain); !_tNodeHead yyHead; ! 
  213.        ForallAttributes (t, TypeDeclNode);
  214.        !} y! WI (Name); !;!
  215.     END;
  216. }; .
  217. Child (..) :- {
  218.     WI (itTree); ! ! WI (Name); !; ! 
  219. }; .
  220. Attribute (..) :- {
  221.     IF (NoCodeAttr * Properties) = {} THEN 
  222.        WI (Type); ! ! WI (Name); !; ! 
  223.     END;
  224. }; .
  225.  
  226.  
  227. PROCEDURE TypeDeclRecord (t: Tree)
  228.  
  229. Class (..) :- {
  230.     IF (NoCodeClass * Properties) = {} THEN
  231.        ! y! WI (Name); ! ! WI (Name); !;!
  232.     END;
  233. }; .
  234.  
  235.  
  236. PROCEDURE ProcedureDeclsn (t: Tree)
  237.  
  238. Class (..) :- {
  239.     IF (NoCodeClass * Properties) = {} THEN
  240.        !extern ! WI (itTree); ! n! WI (Name); ! ();!
  241.     END;
  242. }; .
  243.  
  244.  
  245. PROCEDURE ProcedureDeclsm (t: Tree)
  246.  
  247. Class (..) :- {
  248.     IF (NoCodeClass * Properties) = {} THEN
  249.        !extern ! WI (itTree); ! m! WI (Name); ! ARGS((! 
  250.        ListCount := 0;
  251.        ForallAttributes (t, ProcedureDeclsm);
  252.        !));!
  253.     END;
  254. }; .
  255. Child (..) :- {
  256.     IF Input IN Properties THEN
  257.        IF ListCount > 0 THEN !, ! END;
  258.        WI (itTree); ! p! WI (Name);
  259.        INC (ListCount);
  260.     END;
  261. }; .
  262. Attribute (..) :- {
  263.     IF Input IN Properties THEN
  264.        IF ListCount > 0 THEN !, ! END;
  265.        WI (Type); ! p! WI (Name);
  266.        INC (ListCount);
  267.     END;
  268. }; .
  269.  
  270.  
  271. PROCEDURE ProcedureHeadingm (t: Tree)
  272.  
  273. Class (..) :- {
  274.     IF (NoCodeClass * Properties) = {} THEN
  275.        WI (itTree); ! m! WI (Name); !!
  276.        !# if defined __STDC__ | defined __cplusplus!
  277.        ListCount := 0;
  278.        !(! ForallAttributes (t, ProcedureDeclsm); !)!
  279.        !# else!
  280.        ListCount := 0;
  281.        !(! ForallAttributes (t, ProcedureHeadingm); !)!
  282.        ForallAttributes (t, ProcedureHeadingm2);
  283.        !# endif!
  284.     END;
  285. }; .
  286. Child (..) :- {
  287.     IF Input IN Properties THEN
  288.        IF ListCount > 0 THEN !, ! END;
  289.        !p! WI (Name);
  290.        INC (ListCount);
  291.     END;
  292. }; .
  293. Attribute (..) :- {
  294.     IF Input IN Properties THEN
  295.        IF ListCount > 0 THEN !, ! END;
  296.        !p! WI (Name);
  297.        INC (ListCount);
  298.     END;
  299. }; .
  300.  
  301.  
  302. PROCEDURE ProcedureHeadingm2 (t: Tree)
  303.  
  304. Child (..) :- {
  305.     IF Input IN Properties THEN
  306.        WI (itTree); ! p! WI (Name); !;!
  307.     END;
  308. }; .
  309. Attribute (..) :- {
  310.     IF Input IN Properties THEN
  311.        WI (Type); ! p! WI (Name); !;!
  312.     END;
  313. }; .
  314.  
  315.  
  316. PROCEDURE TreeImplC (t: Tree)
  317.  
  318. Ag (..) :- {
  319.     @# include "@ WI (iMain); @.h"@
  320.     !# define yyALLOC(ptr, size)    if ((ptr = (! WI (itTree); !) ! WI (iMain); !_PoolFreePtr) >= (! WI (itTree); !) ! WI (iMain); !_PoolMaxPtr) \!
  321.     !  ptr = ! WI (iMain); !_Alloc (); \!
  322.     !  ! WI (iMain); !_PoolFreePtr += size;!
  323.     !# define yyFREE(ptr, size)    !
  324.     !# include <stdio.h>!
  325.     !# ifdef __cplusplus!
  326.     @extern "C" {@
  327.     @# include "System.h"@
  328.     @# include "General.h"@
  329.     @# include "Memory.h"@
  330.     @# include "DynArray.h"@
  331.     @# include "StringMem.h"@
  332.     @# include "Idents.h"@
  333.     @# include "Sets.h"@
  334.     @# include "Positions.h"@
  335.     !}!
  336.     !# else!
  337.     @# include "System.h"@
  338.     @# include "General.h"@
  339.     @# include "Memory.h"@
  340.     @# include "DynArray.h"@
  341.     @# include "StringMem.h"@
  342.     @# include "Idents.h"@
  343.     @# include "Sets.h"@
  344.     @# include "Positions.h"@
  345.     !# endif!
  346.     !!
  347.     WriteLine (TreeCodes^.Codes.GlobalLine);
  348.     WriteText (f, TreeCodes^.Codes.Global);
  349.     Node := Modules;
  350.     WHILE Node^.Kind = Tree.Module DO
  351.        WriteLine (Node^.Module.TreeCodes^.Codes.GlobalLine);
  352.        WriteText (f, Node^.Module.TreeCodes^.Codes.Global);
  353.        Node := Node^.Module.Next;
  354.     END;
  355.     WriteLine (TreeCodes^.Codes.LocalLine);
  356.     WriteText (f, TreeCodes^.Codes.Local);
  357.     Node := Modules;
  358.     WHILE Node^.Kind = Tree.Module DO
  359.        WriteLine (Node^.Module.TreeCodes^.Codes.LocalLine);
  360.        WriteText (f, Node^.Module.TreeCodes^.Codes.Local);
  361.        Node := Node^.Module.Next;
  362.     END;
  363.     !# ifdef getchar!
  364.     !# undef getchar!
  365.     !# endif!
  366.     !# ifdef putchar!
  367.     !# undef putchar!
  368.     !# endif!
  369.     @# include "yy@ WI (iModule); @.w"@
  370.     !!
  371.       IF NOT IsElement (ORD ('<'), Options) THEN
  372.     !static void yyExit () { Exit (1); }!
  373.     !!
  374.     !void (* ! WI (iMain); !_Exit) () = yyExit;!
  375.     !!
  376.     !# define yyBlockSize 20480!
  377.     !!
  378.     !typedef struct yysBlock {!
  379.     ! char yyBlock [yyBlockSize];!
  380.     ! struct yysBlock * yySuccessor;!
  381.     !} yytBlock, * yytBlockPtr;!
  382.     !!
  383.     WI (itTree); ! ! WI (iMain); !Root;!
  384.     !unsigned long ! WI (iMain); !_HeapUsed = 0;!
  385.     !!
  386.     !static yytBlockPtr yyBlockList    = (yytBlockPtr) ! WI (iNoTree); !;!
  387.     !char * ! WI (iMain); !_PoolFreePtr    = (char *) ! WI (iNoTree); !;!
  388.     !char * ! WI (iMain); !_PoolMaxPtr    = (char *) ! WI (iNoTree); !;!
  389.     !static unsigned short yyMaxSize    = 0;!
  390.     !unsigned short ! WI (iMain); !_NodeSize [! WN (ClassCount); ! + 1] = { 0,!
  391.     ForallClasses (Classes, InitNodeSize);
  392.     !};!
  393.     !char * ! WI (iMain); !_NodeName [! WN (ClassCount); ! + 1] = {!
  394.     @ "@ WI (iNoTree); @",@
  395.     ForallClasses (Classes, InitNodeName);
  396.     !};!
  397.     !static ! WI (iMain); !_tKind yyTypeRange [! WN (ClassCount); ! + 1] = { 0,!
  398.     ForallClasses (Classes, InitTypeRange);
  399.     !};!
  400.     !!
  401.     WI (itTree); ! ! WI (iMain); !_Alloc ()!
  402.     !{!
  403.     ! register yytBlockPtr yyBlockPtr = yyBlockList;!
  404.     ! register int i;!
  405.     !!
  406.     ! if (yyMaxSize == 0)!
  407.     !  for (i = 1; i <= ! WN (ClassCount); !; i ++) {!
  408.     !   ! WI (iMain); !_NodeSize [i] = (! WI (iMain); !_NodeSize [i] + yyMaxAlign - 1) & yyAlignMasks [yyMaxAlign];!
  409.     !   yyMaxSize = Max (! WI (iMain); !_NodeSize [i], yyMaxSize);!
  410.     !  }!
  411.     ! yyBlockList = (yytBlockPtr) Alloc (sizeof (yytBlock));!
  412.     ! yyBlockList->yySuccessor = yyBlockPtr;!
  413.     ! ! WI (iMain); !_PoolFreePtr = yyBlockList->yyBlock;!
  414.     ! ! WI (iMain); !_PoolMaxPtr = ! WI (iMain); !_PoolFreePtr + yyBlockSize - yyMaxSize + 1;!
  415.     ! ! WI (iMain); !_HeapUsed += yyBlockSize;!
  416.     ! return (! WI (itTree); !) ! WI (iMain); !_PoolFreePtr;!
  417.     !}!
  418.     !!
  419.     WI (itTree); ! Make! WI (iMain); !!
  420.     !# if defined __STDC__ | defined __cplusplus!
  421.     ! (! WI (iMain); !_tKind yyKind)!
  422.     !# else!
  423.     ! (yyKind) ! WI (iMain); !_tKind yyKind;!
  424.     !# endif!
  425.     !{!
  426.     ! register ! WI (itTree); ! yyt;!
  427.     ! yyALLOC (yyt, ! WI (iMain); !_NodeSize [yyKind])!
  428.     ! yyt->Kind = yyKind;!
  429.     ! yyt->yyHead.yyMark = 0;!
  430.       IF IsElement (ORD ('L'), Options) THEN
  431.     ! yyt->yyHead.yyParent = ! WI (iNoTree); !;!
  432.       END;
  433.     ! return yyt;!
  434.     !}!
  435.     !!
  436.     !bool ! WI (iMain); !_IsType!
  437.     !# if defined __STDC__ | defined __cplusplus!
  438.     ! (register ! WI (itTree); ! yyt, register ! WI (iMain); !_tKind yyKind)!
  439.     !# else!
  440.     ! (yyt, yyKind) register ! WI (itTree); ! yyt; register ! WI (iMain); !_tKind yyKind;!
  441.     !# endif!
  442.     !{!
  443.     @ return yyt != @ WI (iNoTree); ! && yyKind <= yyt->Kind && yyt->Kind <= yyTypeRange [yyKind];!
  444.     !}!
  445.     !!
  446.       END;
  447.       IF IsElement (ORD ('n'), Options) THEN
  448.     ForallClasses (Classes, ProcedureBodyn);
  449.       END;
  450.     !!
  451.       IF IsElement (ORD ('m'), Options) THEN
  452.     ForallClasses (Classes, ProcedureBodym);
  453.       END;
  454.     TreeIO (t);
  455.       IF IsElement (ORD ('f'), Options) THEN
  456.     !static ! WI (itTree); ! yyChild;!
  457.     !!
  458.     !static void yyRelease! WI (iModule); !!
  459.     !# if defined __STDC__ | defined __cplusplus!
  460.     ! (! WI (itTree); ! yyt)!
  461.     !# else!
  462.     ! (yyt) ! WI (itTree); ! yyt;!
  463.     !# endif!
  464.     !{!
  465.     ! if (yyt == ! WI (iNoTree); !) return;!
  466.     ! switch (yyt->Kind) {!
  467.     ForallClasses (Classes, ReleaseAttributes1);
  468.     ! default: ;!
  469.     ! }!
  470.     !!
  471.     ! if (-- yyt->yyHead.yyMark == 0) {!
  472.     !  switch (yyt->Kind) {!
  473.     ForallClasses (Classes, ReleaseAttributes2);
  474.     !  default: ;!
  475.     !  }!
  476.     !  yyFREE (yyt, ! WI (iMain); !_NodeSize [yyt->Kind])!
  477.     ! }!
  478.     !}!
  479.     !!
  480.     !void Release! WI (iModule); !!
  481.     !# if defined __STDC__ | defined __cplusplus!
  482.     ! (! WI (itTree); ! yyt)!
  483.     !# else!
  484.     ! (yyt) ! WI (itTree); ! yyt;!
  485.     !# endif!
  486.     !{!
  487.     ! yyMark (yyt);!
  488.     ! yyRelease! WI (iModule); ! (yyt);!
  489.     !}!
  490.     !!
  491.       END;
  492.       IF IsElement (ORD ('F'), Options) AND NOT IsElement (ORD ('<'), Options) THEN
  493.     !void Release! WI (iModule); !Module ()!
  494.     !{!
  495.     ! yytBlockPtr yyBlockPtr;!
  496.     @ while (yyBlockList != (yytBlockPtr) @ WI (iNoTree); @) {@
  497.     !  yyBlockPtr = yyBlockList;!
  498.     !  yyBlockList = yyBlockList->yySuccessor;!
  499.     !  Free (sizeof (yytBlock), (char *) yyBlockPtr);!
  500.     ! }!
  501.     ! ! WI (iMain); !_PoolFreePtr = (char *) ! WI (iNoTree); !;!
  502.     ! ! WI (iMain); !_PoolMaxPtr = (char *) ! WI (iNoTree); !;!
  503.     ! ! WI (iMain); !_HeapUsed = 0;!
  504.     !}!
  505.     !!
  506.       END;
  507.       IF IsElement (ORD ('t'), Options) OR
  508.          IsElement (ORD ('b'), Options) THEN
  509.     !static ! WI (iMain); !_tProcTree yyProc;!
  510.     !!
  511.       END;
  512.       IF IsElement (ORD ('t'), Options) THEN
  513.     !static void yyTraverse! WI (iModule); !TD!
  514.     !# if defined __STDC__ | defined __cplusplus!
  515.     ! (! WI (itTree); ! yyt)!
  516.     !# else!
  517.     ! (yyt) ! WI (itTree); ! yyt;!
  518.     !# endif!
  519.     !{!
  520.     ! for (;;) {!
  521.     !  if (yyt == ! WI (iNoTree); ! || yyt->yyHead.yyMark == 0) return;!
  522.     !  yyt->yyHead.yyMark = 0;!
  523.     !  yyProc (yyt);!
  524.     !!
  525.     !  switch (yyt->Kind) {!
  526.     ForallClasses (Classes, TraverseTD);
  527.     !  default: return;!
  528.     !  }!
  529.     ! }!
  530.     !}!
  531.     !!
  532.     !void Traverse! WI (iModule); !TD!
  533.     !# if defined __STDC__ | defined __cplusplus!
  534.     ! (! WI (itTree); ! yyt, ! WI (iMain); !_tProcTree yyyProc)!
  535.     !# else!
  536.     ! (yyt, yyyProc) ! WI (itTree); ! yyt; ! WI (iMain); !_tProcTree yyyProc;!
  537.     !# endif!
  538.     !{!
  539.     ! yyMark (yyt);!
  540.     ! yyProc = yyyProc;!
  541.     ! yyTraverse! WI (iModule); !TD (yyt);!
  542.     !}!
  543.     !!
  544.       END;
  545.       IF IsElement (ORD ('b'), Options) THEN
  546.     !static void yyTraverse! WI (iModule); !BU!
  547.     !# if defined __STDC__ | defined __cplusplus!
  548.     ! (! WI (itTree); ! yyt)!
  549.     !# else!
  550.     ! (yyt) ! WI (itTree); ! yyt;!
  551.     !# endif!
  552.     !{!
  553.     ! if (yyt == ! WI (iNoTree); ! || yyt->yyHead.yyMark == 0) return;!
  554.     ! yyt->yyHead.yyMark = 0;!
  555.     !!
  556.     ! switch (yyt->Kind) {!
  557.     ForallClasses (Classes, TraverseBU);
  558.     ! default: ;!
  559.     ! }!
  560.     ! yyProc (yyt);!
  561.     !}!
  562.     !!
  563.     !void Traverse! WI (iModule); !BU!
  564.     !# if defined __STDC__ | defined __cplusplus!
  565.     ! (! WI (itTree); ! yyt, ! WI (iMain); !_tProcTree yyyProc)!
  566.     !# else!
  567.     ! (yyt, yyyProc) ! WI (itTree); ! yyt; ! WI (iMain); !_tProcTree yyyProc;!
  568.     !# endif!
  569.     !{!
  570.     ! yyMark (yyt);!
  571.     ! yyProc = yyyProc;!
  572.     ! yyTraverse! WI (iModule); !BU (yyt);!
  573.     !}!
  574.     !!
  575.       END;
  576.       IF IsElement (ORD ('R'), Options) THEN
  577.     WI (itTree); ! Reverse! WI (iModule); !!
  578.     !# if defined __STDC__ | defined __cplusplus!
  579.     ! (! WI (itTree); ! yyOld)!
  580.     !# else!
  581.     ! (yyOld) ! WI (itTree); ! yyOld;!
  582.     !# endif!
  583.     !{!
  584.     ! register ! WI (itTree); ! yyNew, yyNext, yyTail;!
  585.     ! yyNew = yyOld;!
  586.     ! yyTail = yyOld;!
  587.     ! for (;;) {!
  588.     !  switch (yyOld->Kind) {!
  589.     ForallClasses (Classes, Reverse1);
  590.     !  default: goto yyExit;!
  591.     !  }!
  592.     !  yyNew = yyOld;!
  593.     !  yyOld = yyNext;!
  594.     ! }!
  595.     !yyExit:!
  596.     ! switch (yyTail->Kind) {!
  597.     ForallClasses (Classes, Reverse2);
  598.     ! default: ;!
  599.     ! }!
  600.     ! return yyNew;!
  601.     !}!
  602.     !!
  603.       END;
  604.       IF IsElement (ORD ('y'), Options) THEN
  605.         !# define yyInitOldToNewStoreSize 32!
  606.     !!
  607.     !typedef struct { ! WI (itTree); ! yyOld, yyNew; } yytOldToNew;!
  608.         !static unsigned long yyOldToNewStoreSize = yyInitOldToNewStoreSize;!
  609.         !static yytOldToNew yyOldToNewStore [yyInitOldToNewStoreSize];!
  610.         !static yytOldToNew * yyOldToNewStorePtr = yyOldToNewStore;!
  611.     !static int yyOldToNewCount;!
  612.     !!
  613.     !static void yyStoreOldToNew!
  614.     !# if defined __STDC__ | defined __cplusplus!
  615.     ! (! WI (itTree); ! yyOld, ! WI (itTree); ! yyNew)!
  616.     !# else!
  617.     ! (yyOld, yyNew) ! WI (itTree); ! yyOld, yyNew;!
  618.     !# endif!
  619.     !{!
  620.     ! if (++ yyOldToNewCount == yyOldToNewStoreSize)!
  621.     !  ExtendArray ((char * *) & yyOldToNewStorePtr, & yyOldToNewStoreSize, sizeof (yytOldToNew));!
  622.     ! yyOldToNewStorePtr [yyOldToNewCount].yyOld = yyOld;!
  623.     ! yyOldToNewStorePtr [yyOldToNewCount].yyNew = yyNew;!
  624.     !}!
  625.     !!
  626.     !static ! WI (itTree); ! yyMapOldToNew!
  627.     !# if defined __STDC__ | defined __cplusplus!
  628.     ! (! WI (itTree); ! yyOld)!
  629.     !# else!
  630.     ! (yyOld) ! WI (itTree); ! yyOld;!
  631.     !# endif!
  632.     !{!
  633.     ! register int yyi;!
  634.     ! for (yyi = 1; yyi <= yyOldToNewCount; yyi ++)!
  635.     !  if (yyOldToNewStorePtr [yyi].yyOld == yyOld) return yyOldToNewStorePtr [yyi].yyNew;!
  636.     !}!
  637.     !!
  638.     !static ! WI (itTree); ! yyCopy! WI (iModule); !!
  639.     !# if defined __STDC__ | defined __cplusplus!
  640.     ! (! WI (itTree); ! yyt, yyPtrtTree yyNew)!
  641.     !# else!
  642.     ! (yyt, yyNew) ! WI (itTree); ! yyt; yyPtrtTree yyNew;!
  643.     !# endif!
  644.     !{!
  645.     ! for (;;) {!
  646.     !  if (yyt == ! WI (iNoTree); !) { * yyNew = ! WI (iNoTree); !; return; }!
  647.     !  if (yyt->yyHead.yyMark == 0) { * yyNew = yyMapOldToNew (yyt); return; }!
  648.     !  yyALLOC (* yyNew, ! WI (iMain); !_NodeSize [yyt->Kind])!
  649.     !  if (yyt->yyHead.yyMark > 1) { yyStoreOldToNew (yyt, * yyNew); }!
  650.     !  yyt->yyHead.yyMark = 0;!
  651.     !!
  652.     !  switch (yyt->Kind) {!
  653.     ForallClasses (Classes, Copy);
  654.     !  default: ;!
  655.     !  }!
  656.     ! }!
  657.     !}!
  658.     !!
  659.     WI (itTree); ! Copy! WI (iModule); !!
  660.     !# if defined __STDC__ | defined __cplusplus!
  661.     ! (! WI (itTree); ! yyt)!
  662.     !# else!
  663.     ! (yyt) ! WI (itTree); ! yyt;!
  664.     !# endif!
  665.     !{!
  666.     ! ! WI (itTree); ! yyNew;!
  667.     ! yyMark (yyt);!
  668.     ! yyOldToNewCount = 0;!
  669.     ! yyCopy! WI (iModule); ! (yyt, & yyNew);!
  670.     ! return yyNew;!
  671.     !}!
  672.     !!
  673.       END;
  674.       IF IsElement (ORD ('k'), Options) THEN
  675.     !static bool yyCheck! WI (iModule); ! ARGS((! WI (itTree); ! yyt));!
  676.     !!
  677.     !bool Check! WI (iModule); !!
  678.     !# if defined __STDC__ | defined __cplusplus!
  679.     ! (! WI (itTree); ! yyt)!
  680.     !# else!
  681.     ! (yyt) ! WI (itTree); ! yyt;!
  682.     !# endif!
  683.     !{!
  684.     ! yyMark (yyt);!
  685.     ! return yyCheck! WI (iModule); ! (yyt);!
  686.     !}!
  687.     !!
  688.     !static bool yyCheckChild!
  689.     !# if defined __STDC__ | defined __cplusplus!
  690.     ! (! WI (itTree); ! yyParent, ! WI (itTree); ! yyyChild, ! WI (iMain); !_tKind yyType, char * yySelector)!
  691.     !# else!
  692.     ! (yyParent, yyyChild, yyType, yySelector)!
  693.     ! ! WI (itTree); ! yyParent, yyyChild;!
  694.     ! ! WI (iMain); !_tKind yyType;!
  695.     ! char * yySelector;!
  696.     !# endif!
  697.     !{!
  698.     ! bool yySuccess = ! WI (iMain); !_IsType (yyyChild, yyType);!
  699.     @ if (! yySuccess) {@
  700.     @  (void) fputs ("CheckTree: parent = ", stderr);@
  701.     !  Write! WI (iModule); !Node (stderr, yyParent);!
  702.     @  (void) fprintf (stderr, "\nselector: %s child = ", yySelector);@
  703.     !  Write! WI (iModule); !Node (stderr, yyyChild);!
  704.     !  (void) fputc ('\n', stderr);!
  705.     ! }!
  706.     ! return yyCheck! WI (iModule); ! (yyyChild) && yySuccess;!
  707.     !}!
  708.     !!
  709.     !static bool yyCheck! WI (iModule); !!
  710.     !# if defined __STDC__ | defined __cplusplus!
  711.     ! (! WI (itTree); ! yyt)!
  712.     !# else!
  713.     ! (yyt) ! WI (itTree); ! yyt;!
  714.     !# endif!
  715.     !{!
  716.     ! bool yyResult;!
  717.     ! if (yyt == ! WI (iNoTree); !) return false;!
  718.     ! else if (yyt->yyHead.yyMark == 0) return true;!
  719.     ! yyt->yyHead.yyMark = 0;!
  720.     !!
  721.     ! yyResult = true;!
  722.     ! switch (yyt->Kind) {!
  723.     ForallClasses (Classes, CheckAttributes);
  724.     ! default: ;!
  725.     ! }!
  726.     ! return yyResult;!
  727.     !}!
  728.     !!
  729.       END;
  730.       IF IsElement (ORD ('q'), Options) THEN
  731.     !# define yyyWrite    1!
  732.     !# define yyyRead    2!
  733.     !# define yyyQuit    3!
  734.     !!
  735.     !static char yyyString [32], yyCh;!
  736.     !static int yyLength, yyState;!
  737.     !!
  738.     !static bool yyyIsEqual!
  739.     !# if defined __STDC__ | defined __cplusplus!
  740.     ! (char * yya)!
  741.     !# else!
  742.     ! (yya) char * yya;!
  743.     !# endif!
  744.     !{!
  745.     ! register int yyi;!
  746.     ! if (yyLength >= 0 && yyyString [yyLength] == ' ') {!
  747.     @  if (yyLength != strlen (yya)) return false;@
  748.     !  for (yyi = 0; yyi < yyLength; yyi ++)!
  749.     @   if (yyyString [yyi] != yya [yyi]) return false;@
  750.     ! } else {!
  751.     !  if (yyLength >= strlen (yya)) return false;!
  752.     !  for (yyi = 0; yyi <= yyLength; yyi ++)!
  753.     @   if (yyyString [yyi] != yya [yyi]) return false;@
  754.     ! }!
  755.     ! return true;!
  756.     !}!
  757.     !!
  758.     !void Query! WI (iModule); !!
  759.     !# if defined __STDC__ | defined __cplusplus!
  760.     ! (! WI (itTree); ! yyt)!
  761.     !# else!
  762.     ! (yyt) ! WI (itTree); ! yyt;!
  763.     !# endif!
  764.     !{!
  765.     ! yyState = yyyWrite;!
  766.     ! for (;;) {!
  767.     !  switch (yyState) {!
  768.     !  case yyyQuit : return;!
  769.     !  case yyyWrite: Write! WI (iModule); !Node (stdout, yyt); yyState = yyyRead;!
  770.     @  case yyyRead : (void) printf ("? "); yyLength = -1; yyCh = getc (stdin);@
  771.     @   while (yyCh != @!'\n' && yyCh > 0)!
  772.     !    { yyyString [++ yyLength] = yyCh; yyCh = getc (stdin); }!
  773.     @   if (yyCh < 0) { (void) fputs ("QueryTree: eof reached\n", stderr);@
  774.     !    yyState = yyyQuit; return; }!
  775.     @   if      (yyyIsEqual ("parent")) { yyState = yyyWrite; return; }@
  776.     @   else if (yyyIsEqual ("quit"  )) { yyState = yyyQuit ; return; }@
  777.     @   else if (yyt != @ WI (iNoTree); !) {!
  778.     !    switch (yyt->Kind) {!
  779.     ForallClasses (Classes, QueryAttributes);
  780.     !    default: ;!
  781.     !    }!
  782.     !   }!
  783.     !  }!
  784.     ! }!
  785.     !}!
  786.     !!
  787.       END;
  788.       IF IsElement (ORD ('='), Options) THEN
  789.     !bool IsEqual! WI (iModule); !!
  790.     !# if defined __STDC__ | defined __cplusplus!
  791.     ! (! WI (itTree); ! yyt1, ! WI (itTree); ! yyt2)!
  792.     !# else!
  793.     ! (yyt1, yyt2) ! WI (itTree); ! yyt1, yyt2;!
  794.     !# endif!
  795.     !{!
  796.     ! if (yyt1 == yyt2) return true;!
  797.     ! if (yyt1 == ! WI (iNoTree); ! || yyt2 == ! WI (iNoTree); @ || yyt1->Kind != yyt2->Kind) return false;@
  798.     ! switch (yyt1->Kind) {!
  799.     ForallClasses (Classes, IsEqualAttributes);
  800.     ! default: return true;!
  801.     ! }!
  802.     !}!
  803.     !!
  804.       END;
  805.       IF IsElement (ORD ('L'), Options) THEN
  806.     MaxBit := 0;
  807.     ForallClasses (Classes, CompMaxBit);
  808.     !void Init! WI (iModule); !!
  809.     !# if defined __STDC__ | defined __cplusplus!
  810.     ! (register ! WI (itTree); ! yyt)!
  811.     !# else!
  812.     ! (yyt) register ! WI (itTree); ! yyt;!
  813.     !# endif!
  814.     !{!
  815.     ! register ! WI (itTree); ! yyr;!
  816.     ! for (;;) {!
  817.     FOR i := 0 TO (MaxBit - 1) DIV BSS DO
  818.        !  yyt->yyHead.yyIsComp! WN (i); ! = 0;!
  819.       IF IsElement (ORD ('5'), Options) THEN
  820.        !  yyt->yyHead.yyIsDone! WN (i); ! = 0;!
  821.       END;
  822.     END;
  823.     !  switch (yyt->Kind) {!
  824.     ForallClasses (Classes, InitAttributes);
  825.     !  default: return;!
  826.     !  }!
  827.     ! }!
  828.     !}!
  829.     !!
  830.       END;
  831.     !void Begin! WI (iModule); ! ()!
  832.     !{!
  833.     WriteLine (TreeCodes^.Codes.BeginLine);
  834.     WriteText (f, TreeCodes^.Codes.Begin);
  835.     Node := Modules;
  836.     WHILE Node^.Kind = Tree.Module DO
  837.        WriteLine (Node^.Module.TreeCodes^.Codes.BeginLine);
  838.        WriteText (f, Node^.Module.TreeCodes^.Codes.Begin);
  839.        Node := Node^.Module.Next;
  840.     END;
  841.     !}!
  842.     !!
  843.     !void Close! WI (iModule); ! ()!
  844.     !{!
  845.     WriteLine (TreeCodes^.Codes.CloseLine);
  846.     WriteText (f, TreeCodes^.Codes.Close);
  847.     Node := Modules;
  848.     WHILE Node^.Kind = Tree.Module DO
  849.        WriteLine (Node^.Module.TreeCodes^.Codes.CloseLine);
  850.        WriteText (f, Node^.Module.TreeCodes^.Codes.Close);
  851.        Node := Node^.Module.Next;
  852.     END;
  853.     !}!
  854. }; .
  855.  
  856.  
  857. PROCEDURE ProcedureBodyn (t: Tree)
  858.  
  859. Class (..) :- {
  860.     IF (NoCodeClass * Properties) = {} THEN
  861.        WI (itTree); ! n! WI (Name); ! () {!
  862.        ! register ! WI (itTree); ! yyt;!
  863.        ! yyALLOC (yyt, ! WI (iMain); !_NodeSize [k! WI (Name); !])!
  864.        ! yyt->Kind = k! WI (Name); !;!
  865.        ! yyt->yyHead.yyMark = 0;!
  866.      IF IsElement (ORD ('L'), Options) THEN
  867.        ! yyt->yyHead.yyParent = ! WI (iNoTree); !;!
  868.      END;
  869.        iClassName := Name;
  870.        ForallAttributes (t, ProcedureBodyn);
  871.        ! return yyt;!
  872.        !}!
  873.        !!
  874.     END;
  875. }; .
  876. Child (..) :- {
  877.     ! begin! WI (itTree); !(yyt->! WI (iClassName); !.! WI (Name); !)!
  878. }; .
  879. Attribute (..) :- {
  880.     IF (NoCodeAttr * Properties) = {} THEN 
  881.        ! begin! WI (Type); !(yyt->! WI (iClassName); !.! WI (Name); !)!
  882.     END;
  883. }; .
  884.  
  885.  
  886. PROCEDURE ProcedureBodym (t: Tree)
  887.  
  888. Class (..) :- {
  889.     IF (NoCodeClass * Properties) = {} THEN
  890.        ProcedureHeadingm (t);
  891.        !{!
  892.        ! register ! WI (itTree); ! yyt;!
  893.        ! yyALLOC (yyt, ! WI (iMain); !_NodeSize [k! WI (Name); !])!
  894.        ! yyt->Kind = k! WI (Name); !;!
  895.        ! yyt->yyHead.yyMark = 0;!
  896.      IF IsElement (ORD ('L'), Options) THEN
  897.        ! yyt->yyHead.yyParent = ! WI (iNoTree); !;!
  898.      END;
  899.        iClassName := Name;
  900.        ForallAttributes (t, ProcedureBodym);
  901.        ! return yyt;!
  902.        !}!
  903.        !!
  904.     END;
  905. }; .
  906. Child (..) :- {
  907.     IF Input IN Properties THEN
  908.        ! yyt->! WI (iClassName); !.! WI (Name); ! = p! WI (Name); !;!
  909.     ELSE
  910.        ! begin! WI (itTree); !(yyt->! WI (iClassName); !.! WI (Name); !)!
  911.     END;
  912. }; .
  913. Attribute (..) :- {
  914.     IF (NoCodeAttr * Properties) = {} THEN 
  915.        IF Input IN Properties THEN
  916.           ! yyt->! WI (iClassName); !.! WI (Name); ! = p! WI (Name); !;!
  917.        ELSE
  918.           ! begin! WI (Type); !(yyt->! WI (iClassName); !.! WI (Name); !)!
  919.        END;
  920.     END;
  921. }; .
  922.  
  923.  
  924. PROCEDURE ReleaseAttributes1 (t: Tree)
  925.  
  926. Class (..) :- {
  927.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  928.        !case k! WI (Name); !:!
  929.        iClassName := Name;
  930.        ForallAttributes (t, ReleaseAttributes1);
  931.        !break;!
  932.     END;
  933. }; .
  934. Child (..) :- {
  935.     !close! WI (itTree); ! (yyt->! WI (iClassName); !.! WI (Name); !)!
  936. }; .
  937.  
  938.  
  939. PROCEDURE ReleaseAttributes2 (t: Tree)
  940.  
  941. Class (..) :- {
  942.     IF ((NoCodeClass * Properties) = {}) AND (HasAttributes IN Properties) THEN
  943.        !case k! WI (Name); !:!
  944.        iClassName := Name;
  945.        ForallAttributes (t, ReleaseAttributes2);
  946.        !break;!
  947.     END;
  948. }; .
  949. Attribute (..) :- {
  950.     IF (NoCodeAttr * Properties) = {} THEN 
  951.        !close! WI (Type); ! (yyt->! WI (iClassName); !.! WI (Name); !)!
  952.     END;
  953. }; .
  954.  
  955.  
  956. PROCEDURE TraverseTD (t: Tree)
  957.  
  958. Class (..) :- {
  959.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  960.        !case k! WI (Name); !:!
  961.        GetIterator (t);
  962.        iClassName := Name;
  963.        ForallAttributes (t, TraverseTD);
  964.        IF Iterator = NoTree THEN
  965.           !return;!
  966.        ELSE
  967.           !yyt = yyt->! WI (iClassName); !.! WI (Iterator^.Child.Name); !; break;!
  968.        END;
  969.     END;
  970. }; .
  971. Child (..) :- {
  972.     IF t # Iterator THEN
  973.        !yyTraverse! WI (iModule); !TD (yyt->! WI (iClassName); !.! WI (Name); !);!
  974.     END;
  975. }; .
  976.  
  977.  
  978. PROCEDURE TraverseBU (t: Tree)
  979.  
  980. Class (..) :- {
  981.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  982.        !case k! WI (Name); !:!
  983.        GetIterator (t);
  984.        iClassName := Name;
  985.        ForallAttributes (t, TraverseBU);
  986.        IF Iterator = NoTree THEN
  987.           !return;!
  988.        ELSE
  989.           !yyTraverse! WI (iModule); !BU (yyt->! WI (iClassName); !.! WI (Iterator^.Child.Name); !); break;!
  990.        END;
  991.     END;
  992. }; .
  993. Child (..) :- {
  994.     IF t # Iterator THEN
  995.        !yyTraverse! WI (iModule); !BU (yyt->! WI (iClassName); !.! WI (Name); !);!
  996.     END;
  997. }; .
  998.  
  999.  
  1000. PROCEDURE Reverse1 (t: Tree)
  1001.  
  1002. Class (..) :- {
  1003.     IF (NoCodeClass * Properties) = {} THEN
  1004.        iClassName := Name;
  1005.        ForallAttributes (t, Reverse1);
  1006.     END;
  1007. }; .
  1008. Child (..) :- {
  1009.     IF Reverse IN Properties THEN
  1010.        !case k! WI (iClassName); !: yyNext = yyOld->! WI (iClassName); !.! WI (Name); !;! 
  1011.        ! yyOld->! WI (iClassName); !.! WI (Name); ! = yyNew; break;!
  1012.     END;
  1013. }; .
  1014.  
  1015.  
  1016. PROCEDURE Reverse2 (t: Tree)
  1017.  
  1018. Class (..) :- {
  1019.     IF (NoCodeClass * Properties) = {} THEN
  1020.        iClassName := Name;
  1021.        ForallAttributes (t, Reverse2);
  1022.     END;
  1023. }; .
  1024. Child (..) :- {
  1025.     IF Reverse IN Properties THEN
  1026.        !case k! WI (iClassName); !: yyTail->! WI (iClassName); !.! WI (Name); ! = yyOld; break;!
  1027.     END;
  1028. }; .
  1029.  
  1030.  
  1031. PROCEDURE Copy (t: Tree)
  1032.  
  1033. Class (..) :- {
  1034.     IF (NoCodeClass * Properties) = {} THEN
  1035.        !case k! WI (Name); !: (* yyNew)->! WI (Name); ! = yyt->! WI (Name); !;!
  1036.        GetIterator (t);
  1037.        iClassName := Name;
  1038.        ForallAttributes (t, Copy);
  1039.        IF Iterator = NoTree THEN
  1040.           !return;!
  1041.        ELSE
  1042.           !yyt = yyt->! WI (Name); !.! WI (Iterator^.Child.Name); !;!
  1043.           !yyNew = & (* yyNew)->! WI (Name); !.! WI (Iterator^.Child.Name); !; break;!
  1044.        END;
  1045.     END;
  1046. }; .
  1047. Child (..) :- {
  1048.     IF t # Iterator THEN
  1049.        !copy! WI (itTree); ! ((* yyNew)->! WI (iClassName); !.! WI (Name); !, ! 
  1050.           !yyt->! WI (iClassName); !.! WI (Name); !)!
  1051.     END;
  1052. }; .
  1053. Attribute (..) :- {
  1054.     IF (NoCodeAttr * Properties) = {} THEN 
  1055.        !copy! WI (Type); ! ((* yyNew)->! WI (iClassName); !.! WI (Name); !, ! 
  1056.           !yyt->! WI (iClassName); !.! WI (Name); !)!
  1057.     END;
  1058. }; .
  1059.  
  1060.  
  1061. PROCEDURE CheckAttributes (t: Tree)
  1062.  
  1063. Class (..) :- {
  1064.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  1065.        !case k! WI (Name); !:!
  1066.        iClassName := Name;
  1067.        ForallAttributes (t, CheckAttributes);
  1068.        !break;!
  1069.     END;
  1070. }; .
  1071. Child (..) :- {
  1072.     !yyResult = yyCheckChild (yyt, yyt->! WI (iClassName); !.! WI (Name); !, k! 
  1073.     WI (Type); @, "@ WI (Name); @") && yyResult;@
  1074. }; .
  1075.  
  1076.  
  1077. PROCEDURE InitTypeRange (t: Tree)
  1078.  
  1079. Class (..) :- {
  1080.     IF (NoCodeClass * Properties) = {} THEN
  1081.        iRange := Name;
  1082.        ForallClasses (Extensions, InitTypeRange2);
  1083.        ! k! WI (iRange); !,!
  1084.     END;
  1085. }; .
  1086.  
  1087.  
  1088. PROCEDURE InitTypeRange2 (t: Tree)
  1089.  
  1090. Class (..) :- {
  1091.     iRange := Name;
  1092. }; .
  1093.  
  1094.  
  1095. PROCEDURE QueryAttributes (t: Tree)
  1096.  
  1097. Class (..) :- {
  1098.     IF ((NoCodeClass * Properties) = {}) AND (HasChildren IN Properties) THEN
  1099.        !case k! WI (Name); !: if (false) ;!
  1100.        iClassName := Name;
  1101.        ForallAttributes (t, QueryAttributes);
  1102.        !break;!
  1103.     END;
  1104. }; .
  1105. Child (..) :- {
  1106.     @else if (yyyIsEqual ("@ WI (Name); @")) Query@ WI (iModule);
  1107.     ! (yyt->! WI (iClassName); !.! WI (Name); !);!
  1108. }; .
  1109.  
  1110.  
  1111. PROCEDURE IsEqualAttributes (t: Tree)
  1112.  
  1113. Class (..) :- {
  1114.     IF ((NoCodeClass * Properties) = {}) AND
  1115.        (({HasChildren, HasAttributes} * Properties) # {}) THEN
  1116.        !case k! WI (Name); !: return true!
  1117.        iClassName := Name;
  1118.        ForallAttributes (t, IsEqualAttributes);
  1119.        !;!
  1120.     END;
  1121. }; .
  1122. Child (..) :- {
  1123.     !&& equal! WI (itTree); ! (yyt1->! WI (iClassName); !.! WI (Name);
  1124.     !, yyt2->! WI (iClassName); !.! WI (Name); !)!
  1125. }; .
  1126. Attribute (..) :- {
  1127.     IF (NoCodeAttr * Properties) = {} THEN 
  1128.        !&& (equal! WI (Type); ! (yyt1->! WI (iClassName); !.! WI (Name);
  1129.        !, yyt2->! WI (iClassName); !.! WI (Name); !))!
  1130.     END;
  1131. }; .
  1132.  
  1133.  
  1134. PROCEDURE InitAttributes (t: Tree)
  1135.  
  1136. Class (..) :-
  1137.     ((NoCodeClass * Properties) = {{}}) AND (HasChildren IN Properties);
  1138.     !case k! WI (Name); !:!
  1139.     GetIterator (t);
  1140.     iClassName := Name;
  1141.     gBitCount := BitCount;
  1142.     ForallAttributes (t, InitAttributes);
  1143. {    IF (Iterator = NoTree) OR NOT (Input IN Iterator^.Child.Properties) THEN
  1144.        !return;!
  1145.     ELSE
  1146.        !yyt = yyt->! WI (iClassName); !.! WI (Iterator^.Child.Name); !; break;!
  1147.     END;
  1148. };    .
  1149. Child (..) :-
  1150.     Input IN Properties;
  1151.     !yyr = yyt->! WI (iClassName); !.! WI (Name); !; yyr->yyHead.yyOffset = ! 
  1152.     WN (gBitCount + BitOffset); !; yyr->yyHead.yyParent = yyt;!
  1153.     t # Iterator;
  1154.     !Init! WI (iModule); ! (yyr);!
  1155.     .
  1156.  
  1157. PROCEDURE InitNodeSize (t: Tree)
  1158.  
  1159. Class (..) :- {
  1160.     IF (NoCodeClass * Properties) = {} THEN
  1161.        ! sizeof (y! WI (Name); !),!
  1162.     END;
  1163. }; .
  1164.  
  1165.  
  1166.  
  1167. PROCEDURE InitNodeName (t: Tree)
  1168.  
  1169. Class (..) :- {
  1170.     IF (NoCodeClass * Properties) = {} THEN
  1171.        @ "@ WI (Name); @",@
  1172.     END;
  1173. }; .
  1174.  
  1175.  
  1176. PROCEDURE CompMaxBit (t: Tree)
  1177.  
  1178. Class (..) :-
  1179.     i := 1;
  1180.     ForallAttributes (t, CompMaxBit);
  1181.     MaxBit := Max (i, MaxBit);
  1182.     .
  1183. Child (..) ;
  1184. Attribute (..) :-
  1185.     ({{Input, Test, Dummy}} * Properties = {{}});
  1186.     INC (i);
  1187.     .
  1188.